#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 10;
int as[N][N];
bool st1[N][N];
bool st2[N][N];
bool st3[N / 3][N / 3][10];
bool dfs(int x, int y)
{
	if (y == 9)
	{
		y = 0;
		x++;
	}
	if (x == 9)
	{
		return true;
	}
	if (as[x][y])
	{
		return dfs(x, y + 1);
	}
	for (int i = 1; i <= 9; i++)
	{
		if (st1[x][i])
		{
			continue;
		}
		if (st2[y][i])
		{
			continue;
		}
		if (st3[x / 3][y / 3][i])
		{
			continue;
		}
		st1[x][i] = true;
		st2[y][i] = true;
		st3[x / 3][y / 3][i] = true;
		as[x][y] = i;
		if (dfs(x, y + 1))
		{
			return true;
		}
		as[x][y] = 0;
		st1[x][i] = false;
		st2[y][i] = false;
		st3[x / 3][y / 3][i] = false;
	}
	return false;
}
int main()
{
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			cin >> as[i][j];
		}
	}
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			if (as[i][j])
			{
				int x = as[i][j];
				st1[i][x] = true;
				st2[j][x] = true;
				st3[i / 3][j / 3][x] = true;
			}
		}
	}
	dfs(0, 0);
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			cout << as[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}